package jdkObserver;

import java.util.Observable;
import java.util.Observer;

/**
 * @Author: linKe
 * @Date: 2022/1/15 11:34
 * @FileName: DogObserver
 * @version: 1.0
 * @Description: 小狗观察
 */
public class DogObserver implements Observer {
    public DogObserver(Subject subject) {
        subject.addObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {
        if(o instanceof Subject) {
            Subject subject = (Subject) o;
            String news = subject.getNews();
            display(news);
        }
    }

    public void display(String news) {
        System.out.println("汪汪 : " + news);
    }
}
